<template><div><h2 id="前言" tabindex="-1"><a class="header-anchor" href="#前言"><span>前言</span></a></h2>
<p>由于最近接到了新需求，需要维护一个老项目,由于node版本太新了,导致无法安装依赖，所以只能进行node版本降级，发现nvm可以配置多个node环境，且配置简单。所以只需要安装nvm即可进行前端环境配置。</p>
<h2 id="下载nvm" tabindex="-1"><a class="header-anchor" href="#下载nvm"><span>下载nvm</span></a></h2>
<p>链接：https://pan.baidu.com/s/1JU-lGGB6Vf0ZQ3zi-NYHUQ
提取码：cbwy</p>
<h2 id="卸载nodejs" tabindex="-1"><a class="header-anchor" href="#卸载nodejs"><span>卸载nodejs</span></a></h2>
<p>如果之前电脑装过node或者volta,请将node和volta卸载干净,同时删除所有与之相关的环境变量</p>
<h2 id="安装nvm" tabindex="-1"><a class="header-anchor" href="#安装nvm"><span>安装nvm</span></a></h2>
<p>双击安装包，选择好两个路径，一路安装即可，安装成功后使用<strong>nvm   -v</strong>查看是否安装成功</p>
<h2 id="修改镜像源进行加速" tabindex="-1"><a class="header-anchor" href="#修改镜像源进行加速"><span>修改镜像源进行加速</span></a></h2>
<div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#61AFEF">1.</span><span style="color:#98C379"> 首先打开nvm安装的地方</span></span>
<span class="line"><span style="color:#61AFEF">如果忘记了，可以使用</span><span style="color:#98C379"> where</span><span style="color:#98C379"> nvm</span><span style="color:#98C379"> 来查看</span></span>
<span class="line"><span style="color:#61AFEF">2.</span><span style="color:#98C379"> 修改配置文件</span><span style="color:#98C379"> setting.txt</span></span>
<span class="line"><span style="color:#61AFEF">添加</span></span>
<span class="line"><span style="color:#61AFEF">node_mirror:</span><span style="color:#98C379"> https://npmmirror.com/mirrors/node/</span></span>
<span class="line"><span style="color:#61AFEF">npm_mirror:</span><span style="color:#98C379">  https://npmmirror.com/mirrors/npm/</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="nvm常用命令" tabindex="-1"><a class="header-anchor" href="#nvm常用命令"><span>nvm常用命令</span></a></h2>
<div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> off</span><span style="color:#98C379">                      //</span><span style="color:#98C379"> 禁用node.js版本管理</span><span style="color:#ABB2BF">(</span><span style="color:#61AFEF">不卸载任何东西</span><span style="color:#ABB2BF">)</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> on</span><span style="color:#98C379">                       //</span><span style="color:#98C379"> 启用node.js版本管理</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> install</span><span style="color:#ABB2BF"> &#x3C;</span><span style="color:#98C379">versio</span><span style="color:#ABB2BF">n>        </span><span style="color:#98C379">//</span><span style="color:#98C379"> 安装node.js的命名version是版本号例如:nvm</span><span style="color:#98C379"> install</span><span style="color:#D19A66"> 8.12.0</span><span style="color:#ABB2BF">(</span><span style="color:#61AFEF">8</span><span style="color:#98C379"> 可以直接填大版本号</span><span style="color:#ABB2BF">)</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> uninstall</span><span style="color:#ABB2BF"> &#x3C;</span><span style="color:#98C379">versio</span><span style="color:#ABB2BF">n>      </span><span style="color:#98C379">//</span><span style="color:#98C379"> 卸载node.js是的命令，卸载指定版本的nodejs，当安装失败时卸载使用</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> 1s</span><span style="color:#98C379">                       //</span><span style="color:#98C379"> 显示所有安装的node.js版本</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> list</span><span style="color:#98C379"> available</span><span style="color:#98C379">           //</span><span style="color:#98C379"> 显示可以安装的所有node.js的版本</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> use</span><span style="color:#ABB2BF"> &#x3C;</span><span style="color:#98C379">versio</span><span style="color:#ABB2BF">n>            </span><span style="color:#98C379">//</span><span style="color:#98C379"> 切换到使用指定的nodejs版本</span><span style="color:#ABB2BF">(</span><span style="color:#61AFEF">可以直接填大版本号</span><span style="color:#ABB2BF">)</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> v</span><span style="color:#98C379">                        //</span><span style="color:#98C379"> 显示nvm版本</span></span>
<span class="line"><span style="color:#61AFEF">nvm</span><span style="color:#98C379"> install</span><span style="color:#98C379"> stable</span><span style="color:#98C379">           //</span><span style="color:#98C379"> 安装最新稳定版</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>官方教程：<br>
https://nvm.uihtm.com/</p>
</blockquote>
</div></template>


